import axios from 'axios'
import qs from 'qs'


var instance = axios.create({
    baseURL: process.env.VUE_APP_URL,
    timeout: 5000
  });

export function getClassify(data) { //获取分类
    return new Promise((resolve, reject) => {
        instance.get('/api/goods_class',qs.stringify(data)).then(res => {
            if(res.data.code==200){
                resolve(res.data)
            }else{
                resolve(res.data)
            }
        }).catch(res => {
            reject(res.data)
        })
    })
}
export function getGoods(data) { //获取商品
    return new Promise((resolve, reject) => {
        instance.get('/api/goods_list', {params:data}).then(res => {
            if(res.data.code==200){
                resolve(res.data)
            }else{
                resolve(res.data)
            }
        }).catch(res => {
            reject(res.data)
        })
    })
}
export function createOrder(data) { //获取商品
    return new Promise((resolve, reject) => {
        instance.post('/api/create_order', data).then(res => {
            if(res.data.code==200){
                resolve(res.data)
            }else{
                resolve(res.data)
            }
        }).catch(res => {
            reject(res.data)
        })
    })
}
